﻿namespace EasyCMS.Common.DataComponents
{
    using System;
    using Pismire;



    ///<summary>
    ///EasyCMS
    ///</summary>
    ///<remarks>
    ///编写人: 唐炜
    ///编写时间 :2008-8-29
    ///修订历史
    ///---------------
    ///</remarks>
    [System.Runtime.Serialization.DataContractAttribute(Name = "Comment", Namespace = "http://schemas.datacontract.org/2004/07/EasyCMS.Common.DataComponents")]
    public class Comment : Pismire.Data.DBComponentBase
    {
        public Comment() { }

        public Comment(int memberID, int subjectID, int parentID, string title, string body, Enums.CommentStatus status)
        {
            this.MemberID = memberID;
            this.SubjectID = subjectID;
            this.ParentID = parentID;
            this.Title = title;
            this.Status = status;
        }

        /// <summary>
        /// 评论作者
        /// </summary>
        public Author Author { get; set; }

        #region MemberID
        /// <summary>
        /// 所属商户ID，1-MAX，查询条件
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public int MemberID
        {
            get { return m_MemberID; }
            set { m_MemberID = value; }
        }
        private int m_MemberID;

        /// <summary>
        /// 所属商户ID，1-MAX，查询条件 正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState MemberID_Validate(ref int memberID)
        {
            return memberID.Validation("MemberID").MoreThan(0).State;
        }
        #endregion

        #region SubjectID
        /// <summary>
        /// 所属商户ID，1-MAX，查询条件
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public int SubjectID
        {
            get { return m_SubjectID; }
            set { m_SubjectID = value; }
        }
        private int m_SubjectID;

        /// <summary>
        /// 所属商户ID，1-MAX，查询条件 正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState SubjectID_Validate(ref int subjectID)
        {
            return subjectID.Validation("SubjectID").MoreThan(0).State;
        }
        #endregion

        #region ParentID
        /// <summary>
        /// 父留言ID，0-MAX
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public int ParentID
        {
            get { return m_ParentID; }
            set { m_ParentID = value; }
        }
        private int m_ParentID;

        /// <summary>
        /// 父留言ID，0-MAX 正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState ParentID_Validate(ref int parentID)
        {
            return parentID.Validation("ParentID").MoreThan(0).State;
        }
        #endregion

        #region Title
        /// <summary>
        /// 评论标题，0-200个中英文数字字符
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public string Title
        {
            get { return m_Title; }
            set { m_Title = value; }
        }
        private string m_Title;

        /// <summary>
        /// 评论标题，0-200个中英文数字字符 正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState Title_Validate(ref string title)
        {
            return title.Validation("Title").LengthBetween(0, 200).Text(ValidationMode.Only).BindValue(ref title).State;
        }
        #endregion

        #region Body
        /// <summary>
        /// 评论内容，0-1000个中英文数字字符
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public string Body
        {
            get { return m_Body; }
            set { m_Body = value; }
        }
        private string m_Body;

        /// <summary>
        /// 评论内容，0-1000个中英文数字字符 正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState Body_Validate(ref string body)
        {
            return body.Validation("Body").LengthBetween(0, 1000).Text(ValidationMode.Only).BindValue(ref body).State;
        }
        #endregion

        #region Status
        /// <summary>
        /// 留言状态，1-未审核，5-已审核，查询条件
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public Enums.CommentStatus Status
        {
            get { return m_Status; }
            set { m_Status = value; }
        }
        private Enums.CommentStatus m_Status;
        #endregion

        #region ViewCount
        /// <summary>
        /// 浏览次数，0-MAX
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public int ViewCount
        {
            get { return m_ViewCount; }
            set { m_ViewCount = value; }
        }
        private int m_ViewCount;

        /// <summary>
        /// 浏览次数，0-MAX 正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState ViewCount_Validate(ref int viewCount)
        {
            return viewCount.Validation("ViewCount").MoreThan(0).State;
        }
        #endregion

        #region Grade01
        /// <summary>
        /// 
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public int Grade01
        {
            get { return m_Grade01; }
            set { m_Grade01 = value; }
        }
        private int m_Grade01;

        /// <summary>
        ///  正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState Grade01_Validate(ref int grade01)
        {
            return grade01.Validation("Grade01").MoreThan(0).State;
        }
        #endregion

        #region Grade02
        /// <summary>
        /// 
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public int Grade02
        {
            get { return m_Grade02; }
            set { m_Grade02 = value; }
        }
        private int m_Grade02;

        /// <summary>
        ///  正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState Grade02_Validate(ref int grade02)
        {
            return grade02.Validation("Grade02").MoreThan(0).State;
        }
        #endregion

        #region Grade03
        /// <summary>
        /// 
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public int Grade03
        {
            get { return m_Grade03; }
            set { m_Grade03 = value; }
        }
        private int m_Grade03;

        /// <summary>
        ///  正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState Grade03_Validate(ref int grade03)
        {
            return grade03.Validation("Grade03").MoreThan(0).State;
        }
        #endregion

        #region Grade04
        /// <summary>
        /// 
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public int Grade04
        {
            get { return m_Grade04; }
            set { m_Grade04 = value; }
        }
        private int m_Grade04;

        /// <summary>
        ///  正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState Grade04_Validate(ref int grade04)
        {
            return grade04.Validation("Grade04").MoreThan(0).State;
        }
        #endregion

        #region Grade05
        /// <summary>
        /// 
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public int Grade05
        {
            get { return m_Grade05; }
            set { m_Grade05 = value; }
        }
        private int m_Grade05;

        /// <summary>
        ///  正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState Grade05_Validate(ref int grade05)
        {
            return grade05.Validation("Grade05").MoreThan(0).State;
        }
        #endregion

        #region AddTime
        /// <summary>
        /// 添加时间，排序条件
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public DateTime AddTime
        {
            get { return m_AddTime; }
            set { m_AddTime = value; }
        }
        private DateTime m_AddTime;

        /// <summary>
        /// 添加时间，排序条件 正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState AddTime_Validate(ref DateTime addTime)
        {
            return addTime.Validation("AddTime").Between(Pismire.ConstValues.DateTime.MinValue, Pismire.ConstValues.DateTime.MaxValue).State;
        }
        #endregion

        #region UpdateTime
        /// <summary>
        /// 更新时间，排序条件
        /// </summary>
        [System.Runtime.Serialization.DataMember()]
        public DateTime UpdateTime
        {
            get { return m_UpdateTime; }
            set { m_UpdateTime = value; }
        }
        private DateTime m_UpdateTime;

        /// <summary>
        /// 更新时间，排序条件 正确性验证
        /// </summary>
        /// <remarks>
        /// </remarks>
        public static ExcuteState UpdateTime_Validate(ref DateTime updateTime)
        {
            return updateTime.Validation("UpdateTime").Between(Pismire.ConstValues.DateTime.MinValue, Pismire.ConstValues.DateTime.MaxValue).State;
        }
        #endregion


        #region IDBComponent Members

        /// <summary>
        /// 检查该实体的所有属性是否合法
        /// </summary>
        /// <returns></returns>
        public override ExcuteState CheckMe()
        {
            ExcuteState state = new ExcuteState();

            state = MemberID_Validate(ref this.m_MemberID);
            if (!state.Succeed) { return state; }

            state = SubjectID_Validate(ref this.m_SubjectID);
            if (!state.Succeed) { return state; }

            state = ParentID_Validate(ref this.m_ParentID);
            if (!state.Succeed) { return state; }

            state = Title_Validate(ref this.m_Title);
            if (!state.Succeed) { return state; }

            state = Body_Validate(ref this.m_Body);
            if (!state.Succeed) { return state; }

            state = ViewCount_Validate(ref this.m_ViewCount);
            if (!state.Succeed) { return state; }

            state = Grade01_Validate(ref this.m_Grade01);
            if (!state.Succeed) { return state; }

            state = Grade02_Validate(ref this.m_Grade02);
            if (!state.Succeed) { return state; }

            state = Grade03_Validate(ref this.m_Grade03);
            if (!state.Succeed) { return state; }

            state = Grade04_Validate(ref this.m_Grade04);
            if (!state.Succeed) { return state; }

            state = Grade05_Validate(ref this.m_Grade05);
            if (!state.Succeed) { return state; }

            state = AddTime_Validate(ref this.m_AddTime);
            if (!state.Succeed) { return state; }

            state = UpdateTime_Validate(ref this.m_UpdateTime);
            if (!state.Succeed) { return state; }

            return state;
        }

        #endregion
    }
}
